Skip to content

Preserve distinct IELR annotation contributions - #876

Merged
ydah merged 1 commit into
masterfrom
fix/preserve-distinct-ielr-annotations
Nov 21, 2026
Merged

ydah merged 1 commit into
masterfrom
fix/preserve-distinct-ielr-annotations

Conversation

@ydah

@ydah ydah commented Nov 14, 2026

Copy link
Copy Markdown
Member

OR-merging contribution matrices from different paths can hide differences in their dominant actions. This makes incompatible lookahead sets appear compatible, allowing IELR to merge states that need to remain separate and reject valid input.

Keep distinct contribution matrices and discard only identical annotations, including the originating state, token, and actions. This follows Bison's annotation insertion policy (https://github.com/akimd/bison/blob/v3.8.2/src/AnnotationList.c#L62-L142). Remove the unused matrix-merging method.

Build each receiving state's insertion index once per annotation propagation pass and update it as annotations arrive. Keep the indexes local to that pass so independent calls rebuild them from the current annotations.

Measured on Ruby 4.0.9, arm64 macOS, with YJIT disabled and 12 balanced, randomized comparisons per mode. Before is master at 970b304; After is 69432fd. All values are means. CLI timings include startup and C output generation, excluding reports. Warm measurements follow one warm-up run and GC.start.

parse.y measurement Before After
CLI elapsed time 1.610s 1.420s
Warm total CPU time 1.496s 1.289s
Warm annotation propagation CPU time 0.587s 0.375s
Warm allocated objects 4,707,007 3,843,016
Warm GC count 16.25 13.67
Warm GC time 0.162s 0.155s
CLI peak RSS 144.0 MiB 156.3 MiB

CLI elapsed time improves in all 12 comparisons, with a paired mean reduction of 11.8% and a bootstrap 95% interval of 10.6–13.0%. Allocations decrease by 18.4%. Peak RSS increases by 8.7%, and warm GC time shows no clear improvement. The two smaller grammars show no clear overall time change.

The regression parser previously rejected bbc; it now accepts it. It agrees with Bison 3.8.2's IELR and canonical LR parsers on all 9,841 strings over a, b, and c of length 0–8. All 770 specs pass. A 267-grammar comparison against master changes only the new regression fixture; Ruby's parse.y produces identical C and reports.

@ydah
ydah force-pushed the fix/preserve-distinct-ielr-annotations branch from 69432fd to 1e36764 Compare November 14, 2026 07:33
@ydah ydah changed the title Fix/preserve distinct ielr annotations Preserve distinct IELR annotation contributions Nov 20, 2026
@ydah
ydah merged commit f00087c into master Nov 21, 2026
45 checks passed
@ydah
ydah deleted the fix/preserve-distinct-ielr-annotations branch November 21, 2026 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant